<template>
  <div class="timer">
    <div class="time-date">
      <div class="time" >
          <span class="time-text" v-text="time.h">14</span><span class="time-text">:</span><span class="time-text" v-text="time.m">55</span>
      </div>
    <div class="date">
        <span v-text="date"></span>
    </div>
    </div>
  </div>
</template>

<script>
    export default {
        name: 'Timer',
        data () {
            return {
              time:{
                  h:"",
                  m:""
              },
              date:""
            }
        },
      created(){
        console.log(new Date());
        var da=new Date();
        var dns;
        var m= ["Jan","Feb","Mar","Apr","Jun","Jul","Aug","Spt","Oct","Nov","Dec"];
        var w=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
        var day=["st","nd","rd","th"];
        var mn=da.getMonth();
        var wn=da.getDay();
        var dn=da.getDate();
        if(((dn)<1) ||((dn)>3)){
          dns=day[3];
        }
        else
        {
          dns=day[(dn)-1];
          if((dn==11)||(dn==12)){
            dns=day[3];
          }
        }
        this.date=m[mn-1]+" "+dn+dns+" " +w[wn-1]+" "+da.getFullYear();
        //设置时间
        var __this=this;
        setInterval(function(){
            __this.time.h=new Date().getHours()<10?'0'+(new Date().getHours()):new Date().getHours();
            __this.time.m=new Date().getMinutes()<10?'0'+(new Date().getMinutes()):new Date().getMinutes();
            console.log(this.m);
        },1000);

      },
      methods:{

      }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .timer{
    width:240px;
    height:120px;
    border-bottom:1px solid #f8f8f8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .time{
      height:40px;
  }
  .time-date{
    height:64px;
    width:140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;

  }
  .time-text{
    color:#918c8c;
    font-size:50px;
    font-family: 微软雅黑;
    line-height:40px;
  }
  .date{
    font-size:9px;
    font-family: 微软雅黑;
    color:#918c8c;
  }
</style>
